/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package program.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import org.jdesktop.swingx.JXDatePicker;


/**
 *
 * @author Johannes
 */
public class CalendarFrame extends JFrame{
    
    public CalendarFrame()
    {
        final JLabel label = new JLabel();
        label.setText("Choose Date by selecting below.");
        
        final JXDatePicker datePicker = new JXDatePicker();
        datePicker.addActionListener(new ActionListener() {
        
            
        public void actionPerformed(ActionEvent e)
        {
            
            
            SimpleDateFormat sdf = new SimpleDateFormat("dd.mm.yyyy");
            datePicker.setFormats(new SimpleDateFormat("dd.mm.yyyy"));
            Date data = datePicker.getDate();
            String st = sdf.format(data);
            System.out.println(data.toString());
            
            JOptionPane.showMessageDialog(datePicker, "Data selezionata = " + st);
        }
        });
        
        getContentPane().add(label);
        getContentPane().add(datePicker);
        pack();
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(400, 300);
        setVisible(true);
        }
        
        
    public static void main(String[] args) {
        CalendarFrame cf = new CalendarFrame();
        
    }

    
    
}
